package com.example.demo.quartz;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

public class SchedulerQuartzJob implements Job {


    @Autowired
    private SendMessageService sendMessageService;

    @Override
    public void execute(JobExecutionContext arg) throws JobExecutionException {

        System.out.println("业务代码 模拟定时调用接口------");
        JobKey key = arg.getJobDetail().getKey();
        String userCode = key.getGroup();
        String remindId = key.getName();

        sendMessageService.messageSend(userCode, remindId);
    }


    @FeignClient(name = "sendMessageFeignClient", url = "localhost:8888")
    public interface SendMessageService {

        @RequestMapping(value = "api/firstTest", method = RequestMethod.GET, consumes = "application/json")
        String messageSend(@RequestParam(value = "param", required = false) String param,
                           @RequestParam(value = "id", required = false) String id);

    }

}
